var app = Vue.createApp({
	data(){
		return{
			ok:true,
			no:false,
			checked:false,
			
			show: 0,
			count: '',
			timer: null,
			
			userInfo:{
				phone:'',
				password:'',
			},
			
			message:[
					{
						country:"中国",
						nation_num:86
					},
					{
						country:"英国",
						nation_num:56
					},
					{
						country:"韩国",
						nation_num:111
					}
			],
			
			newUserInfo:{
				nation:'中国',
				tel:'',
				test:'',
			}
		}
	},
	methods:{
		tab1(){
			this.ok=true;
			this.no=false;
		},
		tab2(){
			this.no=true;
			this.ok=false;
		},
		saveInfo(){
			var val = this.userInfo.phone;
			if(this.checked == false){
				alert("您还没有同意用户协议！")
			}else{
				console.log("获取到的用户信息",JSON.stringify(this.userInfo));
			}
		},
		saveNewInfo(){
			if(this.checked == false){
				alert("您还没有同意用户协议！")
			}else{
				console.log("获取到的注册用户信息",JSON.stringify(this.newUserInfo));
			}
		},
		verify(){
			let phone = document.querySelector('#phone');
			if(phone.value == ""){
				alert("请先输入手机号");
			}else{
				const times = 60; // 倒计时时间
					 if (!this.timer) {
					 	this.count = times;
						this.show = 1;
						this.timer = setInterval(() => {
							if (this.count > 0 && this.count <= times) {
								this.count--;
							} else {
								this.show = 2;
								clearInterval(this.timer);
								this.timer = null;
							}
						}, 1000)
					}
				}
			},
			
			
	},
	computed:{
		numChange(){
			var ele;
			var na = this.newUserInfo.nation;
			this.message.forEach(function(item){
				if(na == item.country){
					ele = item;
				}
			})
		return ele.nation_num;
		}
	}
	
}).mount('.form_container');